package erfgame.frontend.desktop.view.terrain.iso.interaction;

import erfgame.core.Point3D;
import erfgame.core.Rotation;
import erfgame.core.world.World;
import erfgame.core.world.WorldDAOManager;
import erfgame.core.world.terrain.BlockSurfaceImageFactoryManager;
import erfgame.core.world.terrain.TerrainUpdate;
import erfgame.core.world.terrain.TerrainUpdateGroup;
import erfgame.core.world.terrain.TerrainUtils;

import erfgame.frontend.desktop.view.terrain.iso.handler.InteractionHandler;

public class TerrainUpdateInteraction implements Interaction {
	
	private World world;
	
	private Point3D position;
	private TerrainUpdateGroup terrainUpdate;
	private Rotation priorityRotation;
	
	private WorldDAOManager worldDAOManager;
	private BlockSurfaceImageFactoryManager bsiFactoryManager;
	
	public TerrainUpdateInteraction( 
			World world, 
			Point3D position, 
			Rotation priorityRotation,
			TerrainUpdateGroup terrainUpdate,
			WorldDAOManager worldDAOManager, 
			BlockSurfaceImageFactoryManager bsiFactoryManager
	) {
		this.world = world;
		this.position = position;
		this.terrainUpdate = terrainUpdate;
		this.worldDAOManager = worldDAOManager;
		this.bsiFactoryManager = bsiFactoryManager;
		this.priorityRotation = priorityRotation;
	}

	public InteractionHandler activate() {
		TerrainUtils.overwriteTerrain(
				world, 
				position.x, 
				position.y, 
				position.z, 
				priorityRotation,
				terrainUpdate, 
				worldDAOManager, 
				bsiFactoryManager
		);
		return null;
	}
}
